//
//  emailViewController.m
//  maocuhuiOASystem
//
//  Created by michael on 16/3/23.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "emailViewController.h"
#import "OASendMessageViewController.h"
#import "OAInBoxViewController.h"
@interface emailViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)NSArray* array;

@end

@implementation emailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName, nil];
[self.navigationController.navigationBar setTitleTextAttributes:attributes];
 self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
   self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.title = @"电子邮件";
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.scrollEnabled = NO;
    _array = [NSArray arrayWithObjects:@"收件箱",@"发件箱",nil];
     self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
   UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = barButtonItem;
    
       

    
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{
return _array.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//       static NSString * cellIdentifier = @"cellIdentifier";
//            UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
//            if (cell == nil) {
//                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
//            }
    UITableViewCell *cell = [[UITableViewCell alloc]init];
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(15, 15, 40, 40)];
    image.image = [UIImage imageNamed: _array[indexPath.row]];
[cell.contentView addSubview:image];
//    cell.imageView.image = [UIImage imageNamed: _array[indexPath.row]];
    cell.imageView.size = CGSizeMake(30 ,30);
    UILabel *textLabel = [[UILabel alloc]init];
    textLabel.frame = CGRectMake(image.right+10, 5, 100, 60);
    textLabel.text = _array[indexPath.row];
    [cell.contentView addSubview:textLabel];
    UILabel  *label= [[UILabel alloc]initWithFrame:CGRectMake(45, 10, 20, 20)];
    label.backgroundColor = [UIColor redColor];
    label.layer.cornerRadius = 10;
    label.layer.masksToBounds = YES;
    label.textAlignment = NSTextAlignmentCenter;
//    label.font = [UIFont boldSystemFontOfSize:2.0];
    label.textColor = [UIColor whiteColor];
    
UIFont *font = [UIFont boldSystemFontOfSize:(10)];
label.font = font;
    [cell.contentView addSubview:label];

    if (indexPath.row==0) {
        label.text = self.reads;
        if ([self.reads integerValue] !=0) {
            label.hidden = NO;
        }else{
         label.hidden = YES;
        }
    }else{
    label.hidden = YES;
    
    }


    
    
    
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 70;
}

- (void )tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

if (indexPath.row==0) {
    OAInBoxViewController *invc = (OAInBoxViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"inbox"];
    invc.string = @"收件箱";
    invc.type = @"1";
    invc.method = KMailPageMethod;
    invc.url = KexchmailURL;
    invc.hidesBottomBarWhenPushed  = YES;
    [self.navigationController pushViewController:invc animated:YES];
}
if(indexPath.row==1) {
    OASendMessageViewController *sendvc = (OASendMessageViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"send"];
    sendvc.hidesBottomBarWhenPushed  = YES;
    [self.navigationController pushViewController:sendvc animated:YES];
}
//if (indexPath.row==2) {
//    OAInBoxViewController *invc = (OAInBoxViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"inbox"];
//        invc.string = @"草稿箱";
//        invc.method = @"draftsPage";
//    invc.url = KexchmailURL;
//    [self.navigationController pushViewController:invc animated:YES];
//}
//if (indexPath.row==3) {
//    OAInBoxViewController *invc = (OAInBoxViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"inbox"];
//        invc.string = @"垃圾箱";
//        invc.method = @"dustbinPage";
//    invc.url = KexchmailURL;
//    [self.navigationController pushViewController:invc animated:YES];
//}



}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
